// set of const value used in math
const GEW_MATH_EPSILON        = 1.0e-6;
const GEW_MATH_EPSILON_SQUARE = 1.0e-12;
const GEW_MATH_PI             = 3.141592653589e+0;
const GEW_MATH_RADIAN_TO_DEGREE = 5.729577951308e+1;
const GEW_MATH_DEGREE_TO_RADIAN = 1.745329251994e-2;
const GEW_MATH_POT_SAMPLER      = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096];
const GEW_MATH_MAX_USHORT       = 65536;

// Fixed point
const GEW_FIXED_POINT_16 = 1;
const GEW_FIXED_POINT_32 = 2;
// Mesh type
const GEW_STATIC_MESH = 1;
const GEW_KEYFRAME_MESH = 2;
const GEW_SKINNED_MESH = 3;
// Mesh render type
const GEW_TRIANGLES_NON_INDICES = 1;
const GEW_TRIANGLES_INDICES = 2;

// interpolate function
const GEW_IF_LINEAR = 0;
const GEW_IF_QUADRATIC = 1;
const GEW_IF_STEP = 2;

// BATCHING mode 
const GEW_NO_BATCH = 0;// No batching
const GEW_STATIC_BATCH = 1;// Good for immoveable and small mesh node ( fastest one)
const GEW_VERTEX_CONSTANTS_BATCH = 2;// Recomment batching mode for almost mesh node

// BATCHING const
const GEW_STATIC_BATCH_RADIUS = 10;// 10m
const GEW_MAX_OBJ_VCB = 25; // the max obj per batch in VERTEX_CONSTANTS_BATCH mode


// Event properties 
const GEW_MOUSE_LEFT    = 0;
const GEW_MOUSE_MIDDLE  = 1;
const GEW_MOUSE_RIGHT   = 2;

// INTERSECTION
const GEW_OUT = -1;
const GEW_INTERSECT = 0;
const GEW_IN = 1;
const GEW_INTERNAL = 2;

// RESOURCE TYPE
const GEW_RESOURCE_MESH = 0;
const GEW_RESOURCE_TEXTURE = 1;
const GEW_RESOURCE_FLOAT_MAP = 2;
const GEW_RESOURCE_FONT_DECS = 3;
const GEW_RESOURCE_ATLAS_DECS = 4;
const GEW_RESOURCE_SCENEGRAPH_JSON = 5;

// RESOURCE DOWNLOAD STATUS
const GEW_DOWNLOAD_STATUS_WAITING = 0;
const GEW_DOWNLOAD_STATUS_RUNNING = 1;
const GEW_DOWNLOAD_STATUS_FINISHED = 2;

// ANIMATION STATE
const GEW_PAUSE = 0;
const GEW_PLAYING = 1;
const GEW_STOP = 2;

// NODE TYPE
const GEW_NODE             = 0;
const GEW_MESH_NODE        = 1;
const GEW_TERRAIN_NODE     = 2;
const GEW_GRASS_NODE       = 3;
const GEW_WATER_NODE       = 4;
const GEW_ANIMATED_MESH_NODE = 5;

// Light type
const GEW_DIRECTION_LIGHT = 1;
// Shadow map bias Matrix
var GEW_SHADOW_BIAS_MAT = new gewMat4();
GEW_SHADOW_BIAS_MAT.set([0.5, 0.0, 0.0, 0.0, 
                     0.0, 0.5, 0.0, 0.0,
                     0.0, 0.0, 0.5, 0.0,
                     0.5, 0.5, 0.5, 1.0]);
                     
// CSM MATERIAL TYPE
const GEW_SHADOW_MESH             = 0;
const GEW_SHADOW_ALPHA_REF        = 1;
const GEW_SHADOW_SKINNED_MESH     = 2;

// DEPTH-MASK MATERIAL TYPE
const GEW_DEPTH_MASK_TERRAIN      = 0;
const GEW_DEPTH_MASK_MESH         = 1;

// PARTICLE SYSTEM TYPE
const GEW_PS_POINT      = 0;
const GEW_PS_SPRITE2D   = 1;
const GEW_PS_STREAK     = 2;
// PARTICLE SYSTEM MAXIMUM ELEMENT
const GEW_PS_MAX_ELEMENT = [100000,16000,50000]; // point ps : 100.000 ; sprite2d ps : 16000; streak ps : 50000;

// NETWORK SOCKET STATUS
const GEW_SOCKET_NOT_CREATED  = -1;
const GEW_SOCKET_CONNECTING   = 0;
const GEW_SOCKET_OPEN   = 1;
const GEW_SOCKET_CLOSING      = 2;
const GEW_SOCKET_CLOSED       = 3;


// Gew register , use them to reduce contructor call ( boot performance )
var gewRegMat0 = new gewMat4();
var gewRegMat1 = new gewMat4();
var gewRegMat2 = new gewMat4();
var gewRegMat3 = new gewMat4();
var gewRegMat4 = new gewMat4();
var gewRegMat5 = new gewMat4();
var gewRegMat6 = new gewMat4();
var gewRegMat7 = new gewMat4();
var gewRegMat8 = new gewMat4();
var gewRegMat9 = new gewMat4();

var gewRegVec0 = new gewVec3();
var gewRegVec1 = new gewVec3();
var gewRegVec2 = new gewVec3();
var gewRegVec3 = new gewVec3();
var gewRegVec4 = new gewVec3();
var gewRegVec5 = new gewVec3();
var gewRegVec6 = new gewVec3();
var gewRegVec7 = new gewVec3();
var gewRegVec8 = new gewVec3();
var gewRegVec9 = new gewVec3();